﻿<%@ Page Language="C#" MasterPageFile="~/Common.Master" AutoEventWireup="true" CodeBehind="file.aspx.cs" Inherits="Pan.file" %>
<%@ MasterType VirtualPath="~/Common.Master" %>

<asp:Content ContentPlaceHolderID="Head" runat="server">
    <link rel="stylesheet" type="text/css" href="/static/css/file.css" />
    <script src="/static/js/file.js"></script>
    <title>文件分享 - 网盘</title>
</asp:Content>
    
<asp:Content ContentPlaceHolderID="Content" runat="server">
<% if(this.code == "" || this.code == null) { %>
    <div class="layui-card empty center">
        <div class="layui-card-header info">
            <i class="layui-icon layui-icon-share"></i> 查看分享
        </div>
        <div class="layui-card-body disp">
            <div class="input">
                <input id="code" placeholder="请输入提取码" class="layui-input">
                <button id="submit" class="layui-btn layui-btn-normal">提取文件</button>
            </div>
        </div>
    </div>
<% } else { %>
    <div class="layui-card main">
        <div class="layui-card-header info">
            <i class="layui-icon layui-icon-share"></i>
            <%=uname%> 的分享 "<%=sharename%>"
        </div>
        <div class="layui-card-header path">
            <span style="margin-right: 10px;">当前位置:</span>
            <span class="layui-breadcrumb"><%=breadcrumb%></span>
        </div>
        <div class="layui-card-body list">
            <asp:SqlDataSource ID="SqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:PanConnectionString %>" SelectCommand="GetShareFile" SelectCommandType="StoredProcedure">
                <SelectParameters>
                    <asp:Parameter Name="fids" Type="String" />
                </SelectParameters>
            </asp:SqlDataSource>
            <asp:ListView ID="FileListView" runat="server" DataKeyNames="id" DataSourceID="SqlDataSource">
                <EmptyDataTemplate>
                    <table id="filelist" lay-filter="filelist" style="display: none;">
                        <thead>
                            <tr>
                                <th lay-data="{type:'checkbox', fixed: 'left'}"></th>
                                <th lay-data="{hide: true}"></th>
                                <th lay-data="{hide: true}"></th>
                                <th lay-data="{hide: true}"></th>
                                <th lay-data="{width:600}">文件名</th>
                                <th lay-data="{width:120}">文件大小</th>
                                <th lay-data="{width:220}">创建时间</th>
                                <th lay-data="{fixed:'right'}"></th>
                            </tr>
                        </thead>
                    </table>
                </EmptyDataTemplate>
                <ItemTemplate>
                    <tr>
                        <td></td>
                        <td><%# Eval("id") %></td>
                        <td><%# Eval("type") %></td>
                        <td><%# Eval("code") %></td>
                        <td><%# int.Parse(Eval("type").ToString()) == 0 ? "<i class=\"icon folder_icon\"></i>" : "<i class=\"icon file_icon\"></i>" %><%# "<span class=\"file_name\">"+Eval("name")+"</span>" %></td>
                        <td><%# string.IsNullOrEmpty(Eval("fsize").ToString()) ? "-" : Convert.ToDouble(Eval("fsize"))/1024.0 >= 1 ? (Convert.ToDouble(Eval("fsize"))/1024.0).ToString("#0.00")  + " MB" : Convert.ToDouble(Eval("fsize")).ToString("#0.00") +" KB"%></td>
                        <td><%# Eval("createTime") %></td>
                        <td></td>
                    </tr>
                </ItemTemplate>
                <LayoutTemplate>
                    <table id="filelist" lay-filter="filelist" style="display: none;">
                        <thead>
                            <tr>
                                <th lay-data="{type:'checkbox', fixed: 'left'}"></th>
                                <th lay-data="{field:'id', hide: true}"></th>
                                <th lay-data="{field:'type', hide: true}"></th>
                                <th lay-data="{field:'code', hide: true}"></th>
                                <th lay-data="{field:'filename', width:600, sort: true, event:'check'}">文件名</th>
                                <th lay-data="{field:'filesize', width:120, sort: true, align:'center'}">文件大小</th>
                                <th lay-data="{field:'filetime', width:220, sort: true, align:'center'}">创建时间</th>
                                <th lay-data="{fixed:'right', align:'center', toolbar: '#option'}"></th>
                            </tr>
                        </thead>
                        <script type="text/html" id="option">
                            <a class="layui-btn layui-btn-xs" lay-event="down">下载</a>
                        </script>
                        <tbody runat="server">
                            <tr id="itemPlaceholder" runat="server"></tr>
                        </tbody>
                    </table>
                </LayoutTemplate>
            </asp:ListView>
            <script>
                layui.use(['table'], function () {
                    layui.table.init('filelist', { height: 'full-260', limit: Number.MAX_VALUE });
                })
            </script>
        </div>
    </div>
<% } %>
</asp:Content>
